<? 
	$title="Center Photo Gallery"; 
	$pageid="3";
	$accessid="a00";
	
	require("required/dbconnect.php");	
	require("required/function.php");
	require("required/header.php");
	
?>
	<script src="required/js/jquery-1.4.2.js"></script>
	<script src="required/js/common_javascript.js"></script>
<?	
		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}
	else
	{
		$msg="";
	}
	
	
	$id=$_GET['id'];
	
	$get_album=mysql_query("select * from os_photoalbum where id=$id")or die(mysql_error());
	
	if(mysql_num_rows($get_album)==0)
	{
		echo "No album found!!";
	}
	else
	{
		$get_photo=mysql_query("select * from os_photogallery where album_id=$id order by order_id asc")or die(mysql_error());
				
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">

<td valign="top">
<table width="95%" cellpadding="2" cellspacing="1">
 
  <?
				if(mysql_num_rows($get_photo)==0)
				{
			?>
				<td valign="top" class="title">Content for <?= mysql_result($get_album,0,"album_name_eng") ?>
				
					<table width="100%" >
						<tr>
							<td width="100%" align="center" valign="middle" colspan="6">
				 			<br><br><br> - No Photo - <br> <br>
						<a href="photo_upload.php?action=new&aid=<?= $id ?>">Upload now</a>
						<br><br><br> <br><br><br> 
						
					
			<?
				}
				else
				{
					
			?>
					<td valign="top" class="title">Photo gallery for :
				<?= mysql_result($get_album,0,"album_name_eng") ?>
				 <div id="divMsg"><?= $msg ?></div>
						<table width="100%" >
						<tr>
							<td colspan="3">
                            	<a href="photo_upload.php?action=new&aid=<?= $id ?>">Upload more pictures</a>
                            	<?
									if($id==10)
									{
										$get_file=mysql_query("select * from os_uploadfiles where type='collection'");
								?>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Downloadable files : 
                                [<a href="collection_file_upload.php">View</a>]
                                <? } ?>
                            </td>
						</tr>
							  <tr>
 <?		
						$row=0;
						$secondrow1="";
						$secondrow2="";
						
						while($photo=mysql_fetch_array($get_photo,MYSQL_ASSOC))
						{
							$piclink=$photo["name"];
							if($photo["width"]-$photo["height"]>0)
							{
								$fix="width=100";
							}
							else
							{
								$fix="height=100";
							}
							
							if($row%5==0)
							{
								$secondrow1="<tr>";
								$secondrow2="</tr>";
							}
							else
							{
								$secondrow1="";
								$secondrow2="";
							}
							
							$photo_id=$photo['id'];
						
				?>
				<?= $secondrow1 ?>
				<td valign="top"  height="50%" align="center"><br>
				<img src='../photo_gallery/thumbnails/<?= $piclink ?>' <?= $fix ?> border="0" alt="<?= $photo['caption'] ?>">
				<br>
				Caption:<?= $photo['caption'] ?>
				<br>
				Order ID:<?= $photo['order_id'] ?>
				<br>
				Created:<?= $photo['create_datetime'] ?>				
				<br>
				<a href='photo_upload.php?action=edit&aid=<?= $id ?>&pid=<?= $photo_id ?>'><img src="images/icons/edit.gif"  border="0"/></a>
				<a href='photo_delete.php?aid=<?= $id ?>&pid=<?= $photo_id ?>'><img src="images/icons/delete.gif"  border="0"/></a>
				</td>
				
				<?
					$row++;
						}
				?>
				<?= $secondrow2; ?>
				<? 
						}
					?>
			</table>
			
			
			</td>
	</tr>
	</table>
	</td>
 	
 
</table>
<? } require("required/footer.php"); ?>
